package com.qf.agro.web.handler;

import com.qf.agro.common.CustomerException;
import com.qf.agro.common.ResultInfo;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * ProjectName: smart-agriculture-parent
 * ClassName: GlobalExceptionHandler
 * Author: chenyaosen
 * Date: 2023/6/29 21:59
 * Description:
 */
@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(CustomerException.class)
    public ResultInfo handleCustomerException(CustomerException e) {
        return ResultInfo.error(e.getMessage());
    }

    @ExceptionHandler(Exception.class)
    public ResultInfo handleSystemException(Exception e) {
        e.printStackTrace();
        return ResultInfo.error("服务器出了点小问题,请稍后再试");
    }
}
